<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>卖家-修改个人信息</title>
<link href="<?php echo $this->_webroot('/user/css/common.css'); ?>" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->_webroot('/user/css/content1.css'); ?>" rel="stylesheet" type="text/css" />
<script src="<?php echo $this->_webroot('/user/js/jquery-1.7.1.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->_webroot('/user/js/common.js'); ?>" type="text/javascript"></script>


 
</head>
<body>
<psp:tags     htmlname='user_topnav1'  iconname='usertopnav1' />
<psp:tags     htmlname='user_topsearch'  iconname='usertopsearch' />

<div class="main">
	<div class="main-left">
    	<div class="title">会员管理中心</div>
        <psp:tags     htmlname='user_menulist'  iconname='usermenulist' />
    </div>
<link href="<?php echo $this->_webroot('/user/css/shoprequest.css'); ?>" rel="stylesheet" type="text/css" />   
    <div class="main-right main_right">
	

            <div class="cont">
                <div class="title_uc"><h3>收货地址</h3></div>               

 


			<table width="100%" border="0" cellspacing="0">
				<tr>
                    <th style="width:50;">收件人</th>
                    <th style="width:150px;">所在地</th>
                    <th style="width:;">详细地址</th>
                    <th style="width:100px;">邮政编码</th>
                    <th style="width:100px;">手机/电话</th>
                    <th style="width:100px;">邮箱</th>
                    <th style="width:60px;">操作</th>
                </tr>
				<?php if(empty($address_rs)){?>
					<tr><td class="name" colspan="7">没有保存的收货地址</td></tr>
				<?php }else{?>
				<?php foreach($address_rs as $val){?>
				<tr class="trcolor">
					<td class="name center"><?php echo $val['useraddress']['to_user_name'];?></td>
                    <td class="name"><?php echo $areas_info[0][$val['useraddress']['user_country']]['area_name'];?> <?php echo $areas_info[1][$val['useraddress']['user_province']]['area_name'];?> <?php echo $areas_info[2][$val['useraddress']['user_city']]['area_name'];?> <?php echo $areas_info[3][$val['useraddress']['user_district']]['area_name'];?></td>
                    <td><?php echo $val['useraddress']['full_address'];?></td>
                    <td class="name"><?php echo $val['useraddress']['zipcode'];?></td>
                    <td class="name"><?php echo $val['useraddress']['mobile'];?>/<?php echo $val['useraddress']['telphone'];?></td>
                    <td class="name"><?php echo $val['useraddress']['email'];?></td>
                    <td class="name"><a href="<?php echo $this->_url('user/address/');?>?address_id=<?php echo $val['useraddress']['id'];?>#newAddress">修改</a><br /><a href="<?php echo $this->_url('user/deladdress/');?>?address_id=<?php echo $val['useraddress']['id'];?>">删除</a>
                    </td>
				</tr>
				<?php }?>
				<?php }?>
			</table>
			
      <form action="<?php echo $this->_url('user/address/');?>?address_id=<?php echo $address_id;?>" method="post" name="form_profile" onsubmit="return checkform();">
       <table id="newAddress" width="100%" border="0" cellspacing="0">
					<tr>
						<th align="left" width="30%">&nbsp;&nbsp;收货信息</th><th width="70%"><span></span></th>
					</tr>
					<tr><td class="textright">联系人：</td>
						<td align="left"><input type="text" name="data[useraddress][to_user_name]" value="<?php echo  $user_info['to_user_name'];?>" maxlength="20" /></td></tr>
					<tr>
						<td class="textright">所在地区：</td>
						<td>
								<span id="user_country">
								<select name="data[useraddress][user_country]" onchange="areachanged(this.value,0);">
									<option value='0'>选择国家</option>
								 <?php   foreach($areas_info[0] as $v){?>
									<option value="<?php echo  $v['id'];?>" <?php  if($v['id']==$user_info['user_country']){echo 'selected';}?>><?php echo  $v['area_name'];?></option>
								<?php }?>
								</select>
								</span>
								
								<span id="user_province"><?php  if($user_info['user_country']){?>
								<select name="data[useraddress][user_province]"  id="province"  onchange="areachanged(this.value,1);">
									<option value='0'>选择省份</option>
								<?php foreach($areas_info[1] as $v) {
										if($v['parent_id'] == $user_info['user_country']){?>
									<option value="<?php echo  $v['id'];?>" <?php   if($v['id']==$user_info['user_province']){echo 'selected';}?>><?php echo  $v['area_name'];?></option>
								<?php 	}
								}?>
								</select>
								<?php }?>
								</span>
								
								<span id="user_city">
								<?php 	 if($user_info['user_province']){?>
								<select name="data[useraddress][user_city]" onchange="areachanged(this.value,2);">
									<option value='0'>选择城市</option>
								    <?php foreach($areas_info[2] as $v) {
										if($v['parent_id'] == $user_info['user_province']){?>
									<option value="<?php echo  $v['id'];?>" <?php  if($v['id']==$user_info['user_city']){echo 'selected';}?>><?php echo  $v['area_name'];?></option>
								<?php 	}
								}?></select>
								<?php }?>
								</span>
								
								<span id="user_district">
								<?php  if($user_info['user_city']) {?>
								<select name="data[useraddress][user_district]">
									<option value='0'>选择地区</option>
								<?php foreach($areas_info[3] as $v) {
										if($v['parent_id'] == $user_info['user_city']){?>
									<option value="<?php echo  $v['id'];?>" <?php   if($v['id']==$user_info['user_district']){echo 'selected';}?>><?php echo  $v['area_name'];?></option>
								<?php 	}
								}?>
								</select>
								<?php }?>
								</span>
						</td>
					</tr>
					<tr><td class="textright">详细地址：</td>
					<td><input type="text" name="data[useraddress][full_address]" value="<?php echo  $user_info['full_address'];?>" style="width:250px;" maxlength="50" /></td></tr>
					<tr><td class="textright">邮政编码：</td>
					<td><input type="text" name="data[useraddress][zipcode]" value="<?php echo  $user_info['zipcode'];?>" maxlength="6" /></td></tr>
					<tr><td class="textright">手机：</td>
						<td><input type="text" name="data[useraddress][mobile]" value="<?php echo  $user_info['mobile'];?>" maxlength="20" /></td></tr>
					<tr><td class="textright">电话：</td>
						<td><input type="text" name="data[useraddress][telphone]" value="<?php echo  $user_info['telphone'];?>" maxlength="20" /></td></tr>
					<tr><td class="textright">邮箱：</td>
						<td><input type="text" name="data[useraddress][email]" value="<?php echo $user_info['email'];?>" maxlength="40" /></td></tr>
						<input type="hidden" name="data[useraddress][id]" value="<?php echo  isset($user_info['id'])?$user_info['id']:'';?>" />
					<tr><td></td><td><span><input type="submit" name="submit" value="提交订单" /></span></td></tr>
				</table>

		</form>			  
			  
			  
            </div>
	
	

        

    </div>
    <div class="clear"></div>
</div>

<div class="footer">
    <psp:tags     htmlname='user_footer_helper'  iconname='userfooterhelper' />

</div>
<script language="JavaScript" src="<?php echo $this->_webroot('servtools/ajax_client/ajax.js');?>"></script>
<script language="JavaScript">
<!--

function areachanged(value,type){
	if(value > 0) {	
		ajax("<?php echo $this->_url('user/getareas');?>","POST","value="+value+"&mode=useraddress&pre=user_&type="+type,function(return_text){
			var return_text = return_text.replace(/[\n\r]/g,"");
			if(return_text==""){
				alert("请重新选择!！");
			} else {
				if(type==0) {
					document.getElementById("user_province").innerHTML = return_text;
					show("user_province");
					hide("user_city");
					hide("user_district");
				} else if(type==1) {
					document.getElementById("user_city").innerHTML = return_text;
					show("user_city");
					hide("user_district");
				} else if(type==2) {
					document.getElementById("user_district").innerHTML = return_text;
					show("user_district");
				}
			}
		});
	} else {
		if(type==2) {
			hide("user_district");
		} else if(type==1) {
			hide("user_district");
			hide("user_city");
		} else if(type==0) {
			hide("user_district");
			hide("user_city");
			hide("user_province");
		}
	}
}


function hide(id) {
	document.getElementById(id).style.display = 'none';
}

function show(id) {
	document.getElementById(id).style.display = '';
}



function checkform(){
	var to_user_name = document.getElementsByName('data[useraddress][to_user_name]')[0];
	if(to_user_name.value==''){
		alert('请填写收件人姓名');
		return false;
	}

	var province = document.getElementsByName('data[useraddress][user_province]')[0];
	if(province.value==0){
		alert('请选择收件人省份');
		return false;
	}

	var city = document.getElementsByName('data[useraddress][user_city]')[0];
	if(city.value==0){
		alert('请选择收件人城市');
		return false;
	}

	var district = document.getElementsByName('data[useraddress][user_district]')[0];
	if(district.value==0){
		alert('请选择收件人地区');
		return false;
	}

	var full_address = document.getElementsByName('data[useraddress][full_address]')[0];
	if(full_address.value==''){
		alert('请填写收件人详细地址');
		return false;
	}

	var zipcode = document.getElementsByName('data[useraddress][zipcode]')[0];
	if(zipcode.value==''){
		alert('请填写邮政编码');
		return false;
	}

	var email = document.getElementsByName('data[useraddress][email]')[0];
	var user_email_reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if(!email.value=='' && !user_email_reg.test(email.value)){
		alert('您填写的邮箱格式不正确');
		return false;
	}

	var user_mobile = document.getElementsByName('data[useraddress][mobile]')[0];
	var reg = /^\d+(\.d+)?$/;

	var user_telphone = document.getElementsByName('data[useraddress][telphone]')[0];
	var tel_reg=/^([0-9]|[-])+$/g ;

	if(user_mobile.value=='' && user_telphone.value=='') {
		alert('对不起，电话和手机至少填写一项。');
		return false;
	} else if(!user_mobile.value=='' && !reg.test(user_mobile.value)) {
		alert('对不起，您输入的手机号码错误。');
		return false;
	} else if(!user_telphone.value=='' && !tel_reg.test(user_telphone.value)) {
		alert('对不起，您输入的电话号码错误。');
		return false;
	}else {
		return true;
	}
}

//-->
</script>
</body>
</html>